package com.yuexunit.operationman.nbsy.module.nurse.ui;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;


import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.base.ExitApplication;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.nurse.ui.fragment.Fragment_end_operation;
import com.yuexunit.operationman.nbsy.module.nurse.ui.fragment.Fragment_intranperative;
import com.yuexunit.operationman.nbsy.module.nurse.ui.fragment.Fragment_other;
import com.yuexunit.operationman.nbsy.module.nurse.ui.fragment.Fragment_preoperative;

import org.kymjs.kjframe.KJActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by chenss on 2017/7/7 0007.
 */

public class Act_Ops_Preview extends KJActivity {
    @Bind(R.id.tv_patient_name)
    TextView tvPatientName;
    @Bind(R.id.tv_patient_sex)
    TextView tvPatientSex;
    @Bind(R.id.tv_patient_visitno)
    TextView tvPatientVisitno;
    @Bind(R.id.tv_patient_disease)
    TextView tvPatientDisease;
    @Bind(R.id.preoperative)
    TextView preoperative;
    @Bind(R.id.intranperative)
    TextView intranperative;
    @Bind(R.id.end_operation)
    TextView endOperation;
    @Bind(R.id.other)
    TextView other;
    @Bind(R.id.preoperative_img)
    ImageView preoperativeImg;
    @Bind(R.id.intranperative_img)
    ImageView intranperativeImg;
    @Bind(R.id.end_operation_img)
    ImageView endOperationImg;
    @Bind(R.id.other_img)
    ImageView otherImg;

    Fragment_preoperative fragmentPreoperative;
    Fragment_intranperative fragment_intranperative;
    Fragment_end_operation fragment_end_operation;
    Fragment_other fragment_other;

    @Override
    public void setRootView() {
        setContentView(R.layout.act_ops_preview);
        ButterKnife.bind(this);
        ExitApplication.getInstance().addActivity(this);
    }

    @Override
    public void initData() {
        super.initData();
        setTitle();
        fragmentPreoperative = new Fragment_preoperative();
        fragment_intranperative = new Fragment_intranperative();
        fragment_end_operation = new Fragment_end_operation();
        fragment_other = new Fragment_other();
        changeFragment(R.id.content, fragmentPreoperative);
    }

    private void setTitle() {
        tvPatientName.setText(AppConfig.NURSEBEAN.getObject().getNursing().getPatientName());
        if (AppConfig.NURSEBEAN.getObject().getNursing().getPatientSex().equals("1")) {
            tvPatientSex.setText("男");
        } else if (AppConfig.NURSEBEAN.getObject().getNursing().getPatientSex().equals("2")) {
            tvPatientSex.setText("女");
        } else {
            tvPatientSex.setText("不详");
        }
        tvPatientVisitno.setText("住院号" + AppConfig.NURSEBEAN.getObject().getNursing().getInHospitalNo());
        tvPatientDisease.setText(AppConfig.NURSEBEAN.getObject().getNursing().getOperationName());
    }


    @OnClick({R.id.titlebar_docadvice_img_back, R.id.iv_preoperative, R.id.iv_intranperative, R.id.iv_end_operation, R.id.iv_other, R.id.tv_submit})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.titlebar_docadvice_img_back:
                finish();
                break;
            case R.id.iv_preoperative:
                preoperativeImg.setBackgroundColor(getResources().getColor(R.color.main_color));
                intranperativeImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                endOperationImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                otherImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                changeFragment(R.id.content, fragmentPreoperative);
                break;
            case R.id.iv_intranperative:
                preoperativeImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                intranperativeImg.setBackgroundColor(getResources().getColor(R.color.main_color));
                endOperationImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                otherImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                changeFragment(R.id.content, fragment_intranperative);
                break;
            case R.id.iv_end_operation:
                preoperativeImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                intranperativeImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                endOperationImg.setBackgroundColor(getResources().getColor(R.color.main_color));
                otherImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                changeFragment(R.id.content, fragment_end_operation);
                break;
            case R.id.iv_other:
                preoperativeImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                intranperativeImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                endOperationImg.setBackgroundColor(getResources().getColor(R.color.transparent));
                otherImg.setBackgroundColor(getResources().getColor(R.color.main_color));
                changeFragment(R.id.content, fragment_other);
                break;
            case R.id.tv_submit:
                finish();
                break;
        }
    }
}
